/*
 * @lc app=leetcode.cn id=1619 lang=typescript
 *
 * [1619] 删除某些元素后的数组均值
 */

// @lc code=start
function trimMean(arr: number[]): number {
    arr.sort((a, b) => a - b);
    const count = Math.floor(arr.length / 20);

    return (
        arr.slice(count, arr.length - count).reduce((a, b) => a + b, 0) /
        (arr.length - 2 * count)
    );
}
// @lc code=end
